package cn.com.bob.controller;

import cn.com.bob.api.OrderApi;
import cn.com.bob.dto.Msg;
import cn.com.bob.entity.Order;
import cn.com.bob.feign.MemberFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/*
* 订单服务管理
* */
@RestController
public class OrderController implements OrderApi {

    @Autowired
    private MemberFeign memberFeign;

    @Value("${server.port}")
    private String port;

    @Override
    public String getPort() {
        return "订单服务端口 " + port;
    }

    @Override
    public String getOrder() {
        return "订单服务 ";
    }

    @Override
    public Msg buyOrder(@RequestBody Order order) {
        System.out.println("订单信息为：" + order);
        return new Msg("购买成功");
    }

    @GetMapping("/orderToMember")
    public String orderToMember(){
        return memberFeign.getMember();
    }
}
